import { ref } from 'vue'
import { createArticle } from '@/api/article'
import { useRouter } from 'vue-router'

export default function useCreateArticle () {
  const router = useRouter()

  const article = ref({
    title: '',
    description: '',
    body: '',
    tagList: []
  })
  const handleSubmit = async () => {
    const { data } = await createArticle(article.value)
    console.log(data)
    router.push('/')
  }
  return {
    article,
    handleSubmit
  }
}
